package com.aaa.config;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DaysBetweenTool {

    public static Double dayComparePrecise(Date startDate, Date sendDate){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            sendDate = sdf.parse(sdf.format(sendDate));
            startDate = sdf.parse(sdf.format(startDate));
        } catch (Exception e) {
            e.printStackTrace();
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(sendDate);
        long time1 = cal.getTimeInMillis();
        cal.setTime(startDate);
        long time2 = cal.getTimeInMillis();
        double between_days = (time2 - time1) / (1000 * 3600 * 24);
        return Double.parseDouble(String.valueOf(between_days/365));
    }
}
